/*
 * Title: 蛇形填数
 * Author: Yuanshun L
 * Created: 28-Sep-2021
 */
#include<stdio.h>
#include<string.h>
#define maxn 10
int res[maxn][maxn];

int main() {
    int n; // width of matrix
    int count=1;
    int i,j;
    scanf("%d",&n);
    memset(res,0,sizeof(res));
    i=0;j=n-1;
    res[i][j] = 1;
    // fill matrix
    for(;count<n*n;){
        while(i+1<n && !res[i+1][j]) res[++i][j] = ++count;
        while(j-1>=0 && !res[i][j-1]) res[i][--j] = ++count;
        while(i-1>=0 && !res[i-1][j]) res[--i][j] = ++count;
        while(j+1<n && !res[i][j+1]) res[i][++j] = ++count;
    }
    // print
    int first = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            printf("%4d",res[i][j]);
        }
        if(first++) printf("\n");
    }
    return 0;
}
